<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Tag;
use App\Http\Requests\Tag\Store;

class TagController extends Controller
{
    //
    public function index()
    {
        $data   = Tag::withTrashed()->get();
        $assign = compact('data');

        return view('admin.tag.index', $assign);
    }
    public function create()
    {
        //
        return view('admin.tag.create');
    }
    public function store(Store $request)
    {
   
        Tag::create($request->except('_token','q'));

        return redirect(url('admin/tag'));
    }
    public function show(Category $category)
    {
       $data   = Category::withTrashed()->orderBy('sort')->get();
        $assign = compact('data');
       dd('ddd');exit;
        return view('admin.category.index', $assign);
    }
    public function edit(Tag $tag)
    {
    	$data=$tag;
         $assign = compact('data');
        return view('admin.tag.edit', $assign);
    }
    public function update(Request $request, Tag $tag)
    {
    	
      $tag->update($request->except('_token','q'));

        return redirect()->back();
    }
    public function destroy($id)
    {
        Tag::destroy($id);

        return redirect(url('admin/tag'));
      
    }
    //恢复删除
    public function restore($id)
    {
        Tag::onlyTrashed()->find($id)->restore();

        return redirect(url('admin/tag'));
    }
//彻底删除
    public function forceDelete($id)
    {
        Tag::onlyTrashed()->find($id)->forceDelete();

        return redirect(url('admin/tag'));
    }
    

}
